import request from "@/utils/request"
import { useRoute } from "vue-router"
// import { use当前url } from '@/hooks/hook';
import use路由 from "@/hooks/use路由"
// export default API

export default function (url = "") {
    if (!url) {
        url = use路由().api路径.value
    }

    const 增 = data => {
        return request({
            url,
            method: "post",
            data,
        })
    }
    const 删 = params => {
        return request({
            url,
            method: "delete",
            params,
        })
    }
    const 查 = params => {
        return request({
            url,
            method: "get",
            params,
        })
    }
    
    const 成候选值 = params => {
        return request({
            url,
            method: "get",
            params,
        })
    }

    const 查候选值集 = params => {
        return request({
            url: url + "/查候选值集",
            method: "get",
            params,
        })
    }

    const 查外键关联字段集 = params => {
        return request({
            url: url + "/查外键关联字段集",
            method: "get",
            params,
        })
    }

    const 改 = data => {
        // console.log(`改 data 👉`, data)
        return request({
            url,
            method: "put",
            data,
        })
    }

    return { 增, 删, 改, 查, 查候选值集, 查外键关联字段集, 成候选值 }
}
